package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.UserBean;
import cn.jhc.dao.ConnectionFactory;
import cn.jhc.dao.NewUserDao;

@WebServlet(name = "add event", urlPatterns = { "/goto.do" })
public class GotoServlet extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		String Act_id =(String) req.getParameter("act_id");
		int act_id = Integer.parseInt(Act_id);
		String classname = (String) req.getParameter("classname");
		String room = (String) req.getParameter("bedroom");
		String name = (String) req.getParameter("name");
		String phone = (String) req.getParameter("phone");
		String email = (String) req.getParameter("email");
		UserBean user = (UserBean) req.getSession().getAttribute("user");
		int userid = user.getId();
		NewUserDao dao = new NewUserDao();
		dao.setCon(ConnectionFactory.getConnection());
		dao.ToEvent(classname, room, name, phone, email, act_id,userid);
		RequestDispatcher dispatcher = req.getRequestDispatcher("/activities.jsp");
		dispatcher.forward(req, resp);
	}

}
